Public Transportation Accessibility in Twin Cities
Author
Tina Chen, Shirley Jiang, Cynthia Zhang
Published
Invalid Date
Mapping sthe Education Sources in Twin Cities
schools_stops %>%ggplot(aes(x = number_school, y = number_of_stops))+stat_summary_bin(fun ="mean", bins =5, geom ="point")+#divides the number of schools by the number of bins, so Bin 1: 0-10 schools, Bin 2: 10:20, etc. geom_smooth(method ="lm")+labs(x ="Mean Number of Schools (Pre and Post-Secondary) in Tract", y ="Mean Number of Bus Stops in Tract")+# avg # of stops in areas with similar # of schoolstheme_classic()
schools_stops %>%ggplot(aes(x = number_school, y = number_of_stops))+geom_point(alpha =0.5)+geom_smooth(method ="lm")+labs(x ="Number of Schools (Pre and Post-Secondary) in Tract", y ="Number of Bus Stops in Tract")+theme_classic()
function
map
# need help: don't know how to add title with var?census_var_plot <-function(var, title){# using chosen variable to make the map with bus stopsggplot()+geom_sf(data = census2023, aes(fill = {{var}}))+geom_sf(data = stops_sf_county, color ="green", size =0.1)+scale_fill_gradient(low ="orange", high ="blue")+labs(fill="", title =str_to_title(title))}census_var_perc_plot <-function(var, title){# using the percentage of each race to make the map with bus stopsggplot()+geom_sf(data = census2023, aes(fill = {{var}}/population))+geom_sf(data = stops_sf_county, color ="green", size =0.1)+scale_fill_gradient(low ="orange", high ="blue")+labs(fill="", title =str_c("Percentage of ",title))}for(i in1:2){print(census_var_plot(get(name[i]), name[i]))}
# don't know how to modify label y axiscensus_point_plot <-function(var, title){# Function for plotting the linear relationship between chosen variables and the number of bus stops stops_census_join_summ %>%ggplot(aes(x = {{var}}, y = number_of_stops))+geom_point()+geom_smooth(method ="lm")+labs(y ="Number of Bus Stops in Tract",title =str_to_title(title))+theme_classic()}census_point_density_plot <-function(var, title){# Function for plotting the linear relationship between# percentage of each ethnicity group and the number of bus stops stops_census_join_summ %>%ggplot(aes(x = {{var}}/population, y = number_of_stops))+geom_point()+geom_smooth(method ="lm")+labs(y ="Number of Bus Stops in Tract", title =str_c("Percentage of ",title))+theme_classic()}for(i in1:2){print(census_point_plot(get(name[i]), name[i]))}
# total ridership over 5 yearsused_ridership_all %>%group_by(nYear) %>%mutate(Total_Riders =sum(Total_Riders,na.rm =TRUE)) %>%ggplot(aes(x=nYear, y=Total_Riders))+geom_point()+geom_line()+labs(x ="Year", y ="Total Riders")
# 2 comparisons included: weekday vs weekend, and among each yearweekends_weekdays %>%ggplot(aes(x= nYear, y = Total_Riders)) +geom_point()+geom_line()+facet_wrap(~Schedule)+labs(x ="Year", y ="Total Riders")
used_ridership_all %>%filter(!(rte_class %in%c("CommRai","SuburbL","Support"))) %>%group_by(nYear, rte_class) %>%mutate(Total_Riders =sum(Total_Riders,na.rm =TRUE)) %>%ggplot(aes(x=nYear, y = Total_Riders)) +geom_point()+geom_line()+facet_wrap(~rte_class)+labs(x ="Year", y ="Total Riders")
# total ridership for BRT increase because increasing linesused_ridership_all%>%filter(rte_class =="BRT") %>%distinct(nYear,Route) %>%group_by(nYear) %>%summarise(num_BRT =n()) %>%ggplot(aes(x =nYear, y = num_BRT))+geom_point()+geom_line() # the increase of BRT can replace one of the orginal line